package com.tosh;

import static com.tosh.Utils.isNOE;

/**
 * User: arsentyev
 * Date: 06.08.12
 */
public enum XmlName {
    //---------       Tags     ------------------
    BEANS("beans"), BEAN("bean"), PROP("property"), PROPS("properties"), CONSTRUCTOR("constructor-arg"),
    //---------     Attributes   ----------------
    ID("id"), CLASS("class"), NAME("name"), INDEX("index"), REF("ref"), VALUE("value"),
    UNKNOWN("ad31133z");

    private final String xmlName;

    private XmlName(String name){
        this.xmlName = name;
    }

    public static XmlName getByName(String name) {
        if(isNOE(name)) {
            return UNKNOWN;
        }
        for(XmlName xml : XmlName.values()) {
            if(name.equals(xml.xmlName)) {
                return xml;
            }
        }

        return UNKNOWN;
    }
}